$(function () {
    //验证登陆表单
    var login_sub = $("#login_sub");
    var inputs = $("input");
    var fieldset = $("fieldset");
    var NameBool = false,AccBool = false;
    //实时监听输入的值
    inputs.bind('input propertychange',function () {
        var RegularOuntPass = /^[A-Za-z0-9]+$/g;
        var AttrName = $(this).attr("name");
        switch (AttrName){
            case "login_account":
                NameBool = results(inputsLenght($(this),$(this).val().length,8,15,"账号长度为8-15位"), InuptType($(this),$(this).val(),RegularOuntPass,"账号由数字，字母组成"));
                break;
            case "login_pass":
                AccBool = results(inputsLenght($(this),$(this).val().length,8,15,"密码长度为8-15位"), InuptType($(this),$(this).val(),RegularOuntPass,"密码由数字，字母组成"));
                break;
        }
    });
    //鼠标移动事件
    fieldset.bind("mousemove",function () {
        if(NameBool && AccBool){
            login_sub.css("background-color","#0065ff");
            login_sub.attr("disabled",false);
        }else{
            login_sub.css("background-color","gray");
            login_sub.attr("disabled","disabled");
        }
    });
});
//创建一个验证输入框值长度的方法
function inputsLenght(a,ThisLenght,x,y,name) {
    if(ThisLenght >= x && ThisLenght <= y){
        a.siblings("span").text("");
        return true;
    } else{
        console.log("1");
        a.siblings("span").text(name);
        return false;
    }
}
//创建一个输入框验证输入值类型的方法
function InuptType(a,thisVAl,regular,name) {
    if (thisVAl.match(regular) != null) {
        return true;
    }else{
        a.siblings("span").text(name);
        return false;
    }
}
function results(boolx,booly) {
    if(boolx && booly){
        return true;
    }
    return false
}